/*
 * @lc app=leetcode.cn id=1441 lang=typescript
 *
 * [1441] 用栈操作构建数组
 */

// @lc code=start
function buildArray(target: number[], n: number): string[] {
    const result: string[] = [];
    for (let i = 1; i <= n; i++) {
        if (target.length === 0) break;
        if (target[0] === i) {
            target.shift();
            result.push("Push");
        } else {
            result.push("Push");
            result.push("Pop");
        }
    }
    return result;
}
// @lc code=end
